package com.snow.springboot.task;

import com.snow.springboot.entity.NcmsInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.BlockingQueue;

/**
 * @Package: com.snow.springboot.task
 * @ClassName: ProducNcmsTask
 * @Description: 生产NCMS数据线程
 * @author: lurui
 * @Date: 2018/10/24 下午2:43
 * @version:
 */
public class ProducNcmsTask implements Runnable {
    private static final Logger LOGGER = LoggerFactory.getLogger(ProducNcmsTask.class);

    private NcmsInfo ncmsInfo;

    private BlockingQueue<NcmsInfo> queue;

    public ProducNcmsTask(NcmsInfo ncmsInfo, BlockingQueue<NcmsInfo> queue) {
        this.ncmsInfo = ncmsInfo;
        this.queue = queue;
    }

    @Override
    public void run() {
        try {
            queue.put(ncmsInfo);
        } catch (InterruptedException e) {
            e.printStackTrace();
            LOGGER.error("productNcms error.{}", ncmsInfo.getCode());
            Thread.currentThread().interrupt();
        }
    }
}
